<?php

namespace App\Modules\Apicrzs\Http\Controllers\Wechat;

use App\Modules\Apicrzs\Http\Controllers\BaseApicrzsController;
use App\Modules\Apicrzs\Services\Public\LoginWxService;
use App\Modules\Apicrzs\Services\WeChat\RoutineServices;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class AuthController extends BaseApicrzsController
{

    public function __construct(RoutineServices $service)
    {
        $this->service = $service;
    }


    public function silenceAuth(Request $request): JsonResponse
    {
        $res = $this->service->silenceAuth($request->all());
        return $this->sendApiSuccess($res, $this->service->getError());
    }
    public function authLogin(Request $request)
    {
        $data = $this->service->authLogin($request->all());
        return $this->sendApiSuccess($data);
    }
    public function authType(Request $request)
    {
        $data = $this->service->authType($request->all());
        return $this->sendApiSuccess($data);
    }
    /**
     * 授权获取小程序用户手机号 直接绑定
     * @param string $code
     * @param string $iv
     * @param string $encryptedData
     * @param string $spread_code
     * @param string $spread_spid
     * @param string $key
     * @return mixed
     */
    public function authBindingPhone(Request $request)
    {
        $data = $this->service->authBindingPhone($request->all());
        if ($data){
            return $this->sendApiSuccess($data);
        }else{
            return $this->sendApiError($this->service->getError());
        }
    }
    public function getWxGzhSign(Request $request)
    {
        $data = $this->service->getWxGzhSign($request->all());
        return $this->sendApiSuccess($data);
    }

}
